package com.powernode.teatraceability.dao.circulationprocessmgt;

import com.powernode.teatraceability.pojo.circulationprocessmgt.TransportInfo;
import com.powernode.teatraceability.pojo.circulationprocessmgt.WlDetailInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TransportInfoMapper {

    List<TransportInfo> selectLike(@Param("qydm") String qydm,@Param("shiperName") String shiperName);

    List<TransportInfo> selectAll(String qydm);

    @Select("select t.id id, t.qydm qydm, pch, number, cpmc, shiper_name, shiper_phone , " +
            "ship_address, destination , accepter, client_id, carrier, carrier_phone, license, " +
            "courier_number, waybill_pic, cargo_pic, delivery_time, tc.create_time create_time, " +
            "order_number, tc.qydm cqydm, client_firm, client_name, client_phone, client_address," +
            " client_source from t_transport t join t_client tc on tc.id = t.client_id " +
            "where t.id = #{id}")
    WlDetailInfo selectById(Integer id);

    int update(TransportInfo transportInfo);

    int insert(TransportInfo transportInfo);
    @Insert("INSERT INTO t_transport(qydm,cpmc,pch,number,shiper_name,shiper_phone,ship_address,destination,accepter,client_id," +
            "carrier,carrier_phone,license,courier_number,waybill_pic,cargo_pic,delivery_time,create_time,order_number)" +
            "VALUES(#{qydm},#{cpmc},#{pch},#{number},#{shiperName},#{shiperPhone},#{shipAddress},#{destination},#{accepter}," +
            "#{clientId},#{carrier},#{carrierPhone},#{license},#{courierNumber},#{waybillPic},#{cargoPic},#{deliveryTime}," +
            "#{createTime},#{orderNumber})")
    int insertWlDetailInfo(WlDetailInfo transportInfo);

    @Select("select count(*) from t_transport where qydm = #{qydm}")
    Integer countInfo(String qydm);
}
